
import 'all_collapse/light_collapse.dart';

class DeviceConfigData {
  bool isLightMode;
  bool isGroupConfig;
  bool isRFConfig;
  int firstGroup;
  int secondGroup;
  LightModeEnum mode;
  int fixedBrightness;
  int lightDelayTime;
  int peopleBrightness;
  int noPeopleBrightness;
  int darkDelayTime;
  bool isForwarding;
  int ttlCount;
  bool isNetwork;
  int power;
  bool isSecondGroup;

  DeviceConfigData({
    required this.isLightMode,
    required this.isGroupConfig,
    required this.isRFConfig,
    required this.firstGroup,
    required this.secondGroup,
    required this.mode,
    required this.fixedBrightness,
    required this.lightDelayTime,
    required this.peopleBrightness,
    required this.noPeopleBrightness,
    required this.darkDelayTime,
    required this.isForwarding,
    required this.ttlCount,
    required this.isNetwork,
    required this.power,
    required this.isSecondGroup,
  });

  Map<String, dynamic> toJson() {
    return {
      // 亮灯模式配置
      'lightmode_setting': isLightMode ? 1 : 0,
      'mode': mode == LightModeEnum.manual ? 1 : 0,
      'fixedBrightness': fixedBrightness,
      'lightDelayTime': lightDelayTime,
      'peopleBrightness': peopleBrightness,
      'unmannedBrightness': noPeopleBrightness,
      'dark_delay': darkDelayTime,
      // 组别配置
      'group_setting': isGroupConfig ? 1 : 0,
      'new_group': firstGroup,
      'second_group_id': isSecondGroup ? secondGroup : firstGroup,
      'is_second_group': isSecondGroup,
      // rf配置
      'rf_setting': isRFConfig ? 1 : 0,
      'forwarding': isForwarding ? 1 : 0,
      'ttl_count': ttlCount,
      'network': isNetwork ? 1 : 0,
      'tx_power': power,
    };
  }
}
